Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
saucelabs
Advanced tools
The 'saucelabs' npm package provides a Node.js client for interacting with the Sauce Labs API. Sauce Labs is a cloud-based platform for automated testing of web and mobile applications. This package allows you to manage Sauce Labs resources, such as jobs, tunnels, and assets, programmatically.
Managing Jobs
This feature allows you to manage and retrieve details about your Sauce Labs jobs. The code sample demonstrates how to get details of a specific job using its job ID.
const { SauceLabs } = require('saucelabs');
const saucelabs = new SauceLabs({ user: 'your-username', key: 'your-access-key' });
async function getJobDetails(jobId) {
const job = await saucelabs.getJob(jobId);
console.log(job);
}
getJobDetails('your-job-id');
Managing Tunnels
This feature allows you to manage Sauce Connect tunnels. The code sample demonstrates how to list all active tunnels.
const { SauceLabs } = require('saucelabs');
const saucelabs = new SauceLabs({ user: 'your-username', key: 'your-access-key' });
async function getTunnels() {
const tunnels = await saucelabs.listTunnels();
console.log(tunnels);
}
getTunnels();
Uploading Assets
This feature allows you to upload assets to a specific job. The code sample demonstrates how to upload a file to a job using its job ID.
const { SauceLabs } = require('saucelabs');
const saucelabs = new SauceLabs({ user: 'your-username', key: 'your-access-key' });
async function uploadAsset(jobId, filePath) {
const response = await saucelabs.uploadJobAssets(jobId, { files: [filePath] });
console.log(response);
}
uploadAsset('your-job-id', 'path/to/your/file');
WebdriverIO is a popular testing utility for Node.js that provides a high-level API for browser automation. It supports multiple browser drivers and services, including Sauce Labs. Compared to the 'saucelabs' package, WebdriverIO offers a more comprehensive solution for writing and running tests, while 'saucelabs' focuses on managing Sauce Labs resources.
Selenium WebDriver is a widely-used tool for browser automation. It provides bindings for multiple programming languages, including JavaScript. While Selenium WebDriver can be used with Sauce Labs for running tests on their cloud infrastructure, it does not provide the same level of resource management capabilities as the 'saucelabs' package.
Cypress is an end-to-end testing framework that aims to make testing fast, easy, and reliable. It provides a rich API for writing tests and a powerful test runner. While Cypress does not natively integrate with Sauce Labs, it can be configured to run tests on Sauce Labs infrastructure. Compared to 'saucelabs', Cypress focuses more on the testing experience and less on resource management.
Wrapper around the Sauce Labs REST API for Node.js.
npm install saucelabs
To run the test suite, first invoke the following command within the repo, installing the development dependencies:
npm install
Then run the tests:
npm test
var SauceLabs = require('saucelabs');
var myAccount = new SauceLabs({
username: "your-sauce-username",
password: "your-sauce-api-key"
});
myAccount.getAccountDetails(function (err, res) {
console.log(res);
myAccount.getServiceStatus(function (err, res) {
// Status of the Sauce Labs services
console.log(res);
myAccount.getAllBrowsers(function (err, res) {
// List of all browser/os combinations currently supported on Sauce Labs
console.log(res);
myAccount.getJobs(function (err, jobs) {
// Get a list of all your jobs
for (var k in jobs) {
if ( jobs.hasOwnProperty( k )) {
myAccount.showJob(jobs[k].id, function (err, res) {
var str = res.id + ": Status: " + res.status;
if (res.error) {
str += "\033[31m Error: " + res.error + " \033[0m";
}
console.log(str);
});
}
}
});
});
});
});
If you're behind a corporate firewall or would like to utilize a proxy, define it in the constructor like this:
var sauce = new SauceLabs({
username: "your-sauce-username",
password: "your-sauce-api-key",
proxy: "https://your-proxy.com:8000"
});
REST | Node Wrapper |
---|---|
GET /users/:username Access account details. | getAccountDetails(cb) -> cb(err, res) |
GET /:username/limits Access current account limits. | getAccountLimits(cb) -> cb(err, res) |
GET /:username/activity Access current account activity. |
getUserActivity(start, end, cb) -> cb(err, res) getUserActivity(start, cb) -> cb(err, res) getUserActivity(cb) -> cb(err, res) |
GET /users/:username/concurrency Get currently running job counts broken down by account and job status | getUserConcurrency(cb) -> cb(err, res) |
GET /users/:username/usage Access historical account usage data. | getAccountUsage(cb) -> cb(err, res) |
GET /:username/jobs List all job IDs belonging to a given user. | getJobs(cb) -> cb(err, res) |
GET /:username/jobs/:id Show the full information for a job given its ID. | showJob(id, cb) -> cb(err, res) |
PUT /:username/jobs/:id Changes a pre-existing job. | updateJob(id, data, cb) -> cb(err, res) |
DELETE /:username/jobs/:id Removes the job from the system with all the linked assets. | deleteJob(id, cb) -> cb(err, res) |
PUT /:username/jobs/:id/stop Terminates a running job. | stopJob(id, data, cb) -> cb(err, res) |
GET /:username/tunnels Retrieves all running tunnels for a given user. | getActiveTunnels(cb) -> cb(err, res) |
GET /:username/tunnels/:id Show the full information for a tunnel given its ID. | getTunnel(id, cb) -> cb(err, res) |
DELETE /:username/tunnels/:id Shuts down a tunnel given its ID. | deleteTunnel(id, cb) -> cb(err, res) |
GET /info/status Returns the current status of Sauce Labs' services. | getServiceStatus(cb) -> cb(err, res) |
GET /info/browsers/all Returns an array of strings corresponding to all the browsers currently supported on Sauce Labs. | getAllBrowsers(cb) -> cb(err, res) |
GET /info/browsers/selenium-rc Returns an array of strings corresponding to all the browsers currently supported under Selenium on Sauce Labs. | getSeleniumBrowsers(cb) -> cb(err, res) |
GET /info/browsers/webdriver Returns an array of strings corresponding to all the browsers currently supported under WebDriver on Sauce Labs. | getWebDriverBrowsers(cb) -> cb(err, res) |
GET /info/counter Returns the number of test executed so far on Sauce Labs. | getTestCounter(cb) -> cb(err, res) |
POST /users/:username Create a new subaccount. | createSubAccount(data, cb) -> cb(err, res) |
POST /users/:username/subscription Update a subaccount Sauce Labs service plan. | updateSubAccount(data, cb) -> cb(err, res) |
DELETE /users/:username/subscription Unsubscribe a subaccount from its Sauce Labs service plan. | deleteSubAccount(cb) -> cb(err, res) |
Make a public link to a private job, without needing to login. |
createPublicLink(job_id, datetime, use_hour, cb) -> cb(err, url) createPublicLink(job_id, datetime, cb) -> cb(err, url) createPublicLink(job_id, cb) -> cb(err, url) |
GET /users/:username/list-subaccounts Access list of subaccounts | getSubAccountList(cb) -> cb(err, res) |
GET /users/:username/subaccounts Get information about a sub accounts | getSubAccounts(cb) -> cb(err, res) |
Check out the Sauce REST API for more information.
The MIT License (MIT)
Copyright (c) 2013 Dan Jenkins
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
A wrapper around Sauce Labs REST API
The npm package saucelabs receives a total of 685,603 weekly downloads. As such, saucelabs popularity was classified as popular.
We found that saucelabs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.